/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jFPessoas.java
 *
 * Created on 11/03/2012, 11:20:34
 */

package ecommercial;

import ecommercial.Classes.ClassConecta;
import ecommercial.Classes.ColorRenderer;
import ecommercial.Classes.ComboItem;
import ecommercial.Classes.Filiais;
import ecommercial.Classes.Funcoes;
import ecommercial.Classes.Logradouros;
import ecommercial.Classes.Pessoas;
import ecommercial.Classes.PessoasEnderecos;
import ecommercial.Classes.Telefones;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Luciano Carrafa Benfica
 */
public class jFPessoas extends javax.swing.JFrame {


    /** Creates new form jFPessoas */
    public jFPessoas() throws ParseException {
        initComponents();

        pessoajTextField.grabFocus();
        salvarjButton.setEnabled(false);
        salvarMaisjButton.setEnabled(false);
        alterarjButton.setEnabled(false);
        excluirjButton.setEnabled(false);
        editarjButton.setEnabled(false);
        novojButton.setEnabled(true);
        telefonejButton.setEnabled(false);
        enderecosjButton.setEnabled(false);
        pessoaFisicajButton.setEnabled(false);
        pessoaJuridicajButton.setEnabled(false);
        filiaisjButton.setEnabled(false);
        fornecedoresjButton.setEnabled(false);
        cadastrarFiliaisjButton.setEnabled(false);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        buscarjButton = new javax.swing.JButton();
        novojButton = new javax.swing.JButton();
        editarjButton = new javax.swing.JButton();
        salvarjButton = new javax.swing.JButton();
        salvarMaisjButton = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        alterarjButton = new javax.swing.JButton();
        excluirjButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        sairjButton = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        pessoaFisicajButton = new javax.swing.JButton();
        pessoaJuridicajButton = new javax.swing.JButton();
        filiaisjButton = new javax.swing.JButton();
        fornecedoresjButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        gradePessoasjTable = new javax.swing.JTable();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        gradeEnderecosjTable = new javax.swing.JTable();
        enderecosjButton = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        atualizagradeTelefonejButton = new javax.swing.JButton();
        telefonejButton = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        identificadorjSpinner = new javax.swing.JSpinner();
        jLabel2 = new javax.swing.JLabel();
        pessoajTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        dataNascimentojFormattedTextField = new javax.swing.JFormattedTextField();
        dataFalecimentojFormattedTextField = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        dataCadastrojFormattedTextField = new javax.swing.JFormattedTextField();
        jLabel7 = new javax.swing.JLabel();
        filiaisjComboBox = new javax.swing.JComboBox();
        cadastrarFiliaisjButton = new javax.swing.JButton();
        atualizaFiliaisjButton = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        gradeTelefonejTable = new javax.swing.JTable();
        jPanel14 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        observacaojTextArea = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ecommercial.EcommercialApp.class).getContext().getResourceMap(jFPessoas.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setForeground(resourceMap.getColor("Form.foreground")); // NOI18N
        setName("Form"); // NOI18N
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jToolBar1.setBackground(resourceMap.getColor("jToolBar1.background")); // NOI18N
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        buscarjButton.setBackground(resourceMap.getColor("jToolBar1.background")); // NOI18N
        buscarjButton.setIcon(resourceMap.getIcon("buscarjButton.icon")); // NOI18N
        buscarjButton.setText(resourceMap.getString("buscarjButton.text")); // NOI18N
        buscarjButton.setFocusable(false);
        buscarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        buscarjButton.setName("buscarjButton"); // NOI18N
        buscarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        buscarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buscarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(buscarjButton);

        novojButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        novojButton.setIcon(resourceMap.getIcon("novojButton.icon")); // NOI18N
        novojButton.setText(resourceMap.getString("novojButton.text")); // NOI18N
        novojButton.setFocusable(false);
        novojButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        novojButton.setName("novojButton"); // NOI18N
        novojButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        novojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                novojButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(novojButton);

        editarjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        editarjButton.setIcon(resourceMap.getIcon("editarjButton.icon")); // NOI18N
        editarjButton.setText(resourceMap.getString("editarjButton.text")); // NOI18N
        editarjButton.setFocusable(false);
        editarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editarjButton.setName("editarjButton"); // NOI18N
        editarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(editarjButton);

        salvarjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        salvarjButton.setIcon(resourceMap.getIcon("salvarjButton.icon")); // NOI18N
        salvarjButton.setText(resourceMap.getString("salvarjButton.text")); // NOI18N
        salvarjButton.setFocusable(false);
        salvarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        salvarjButton.setName("salvarjButton"); // NOI18N
        salvarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        salvarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(salvarjButton);

        salvarMaisjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        salvarMaisjButton.setIcon(resourceMap.getIcon("salvarMaisjButton.icon")); // NOI18N
        salvarMaisjButton.setText(resourceMap.getString("salvarMaisjButton.text")); // NOI18N
        salvarMaisjButton.setFocusable(false);
        salvarMaisjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        salvarMaisjButton.setName("salvarMaisjButton"); // NOI18N
        salvarMaisjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        salvarMaisjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarMaisjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(salvarMaisjButton);

        jSeparator2.setName("jSeparator2"); // NOI18N
        jToolBar1.add(jSeparator2);

        alterarjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        alterarjButton.setIcon(resourceMap.getIcon("alterarjButton.icon")); // NOI18N
        alterarjButton.setText(resourceMap.getString("alterarjButton.text")); // NOI18N
        alterarjButton.setFocusable(false);
        alterarjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        alterarjButton.setName("alterarjButton"); // NOI18N
        alterarjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        alterarjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                alterarjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(alterarjButton);

        excluirjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        excluirjButton.setIcon(resourceMap.getIcon("excluirjButton.icon")); // NOI18N
        excluirjButton.setText(resourceMap.getString("excluirjButton.text")); // NOI18N
        excluirjButton.setFocusable(false);
        excluirjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        excluirjButton.setName("excluirjButton"); // NOI18N
        excluirjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        excluirjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excluirjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(excluirjButton);

        jSeparator1.setName("jSeparator1"); // NOI18N
        jToolBar1.add(jSeparator1);

        sairjButton.setBackground(resourceMap.getColor("sairjButton.background")); // NOI18N
        sairjButton.setIcon(resourceMap.getIcon("sairjButton.icon")); // NOI18N
        sairjButton.setText(resourceMap.getString("sairjButton.text")); // NOI18N
        sairjButton.setFocusable(false);
        sairjButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        sairjButton.setName("sairjButton"); // NOI18N
        sairjButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        sairjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sairjButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(sairjButton);

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel4.setBackground(resourceMap.getColor("jPanel4.background")); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N

        jPanel3.setBackground(resourceMap.getColor("jPanel3.background")); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        pessoaFisicajButton.setText(resourceMap.getString("pessoaFisicajButton.text")); // NOI18N
        pessoaFisicajButton.setName("pessoaFisicajButton"); // NOI18N
        pessoaFisicajButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pessoaFisicajButtonActionPerformed(evt);
            }
        });

        pessoaJuridicajButton.setText(resourceMap.getString("pessoaJuridicajButton.text")); // NOI18N
        pessoaJuridicajButton.setName("pessoaJuridicajButton"); // NOI18N
        pessoaJuridicajButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pessoaJuridicajButtonActionPerformed(evt);
            }
        });

        filiaisjButton.setText(resourceMap.getString("filiaisjButton.text")); // NOI18N
        filiaisjButton.setName("filiaisjButton"); // NOI18N
        filiaisjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                filiaisjButtonActionPerformed(evt);
            }
        });

        fornecedoresjButton.setText(resourceMap.getString("fornecedoresjButton.text")); // NOI18N
        fornecedoresjButton.setName("fornecedoresjButton"); // NOI18N
        fornecedoresjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fornecedoresjButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pessoaFisicajButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pessoaJuridicajButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(filiaisjButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(fornecedoresjButton)
                .addContainerGap(492, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pessoaFisicajButton)
                    .addComponent(pessoaJuridicajButton)
                    .addComponent(filiaisjButton)
                    .addComponent(fornecedoresjButton))
                .addContainerGap())
        );

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        gradePessoasjTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Identificador", "Pessoa", "Data Cadastro", "Data Nascimento"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        gradePessoasjTable.setName("gradePessoasjTable"); // NOI18N
        gradePessoasjTable.getTableHeader().setReorderingAllowed(false);
        gradePessoasjTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                gradePessoasjTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(gradePessoasjTable);
        gradePessoasjTable.getColumnModel().getColumn(0).setResizable(false);
        gradePessoasjTable.getColumnModel().getColumn(0).setPreferredWidth(80);
        gradePessoasjTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("gradePessoasjTable.columnModel.title0")); // NOI18N
        gradePessoasjTable.getColumnModel().getColumn(1).setResizable(false);
        gradePessoasjTable.getColumnModel().getColumn(1).setPreferredWidth(350);
        gradePessoasjTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("gradePessoasjTable.columnModel.title1")); // NOI18N
        gradePessoasjTable.getColumnModel().getColumn(2).setResizable(false);
        gradePessoasjTable.getColumnModel().getColumn(2).setPreferredWidth(100);
        gradePessoasjTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("gradePessoasjTable.columnModel.title2")); // NOI18N
        gradePessoasjTable.getColumnModel().getColumn(3).setResizable(false);
        gradePessoasjTable.getColumnModel().getColumn(3).setPreferredWidth(100);
        gradePessoasjTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("gradePessoasjTable.columnModel.title3")); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 808, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel7.setBackground(resourceMap.getColor("jPanel7.background")); // NOI18N
        jPanel7.setName("jPanel7"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        gradeEnderecosjTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "#Id", "Endereços", "Tipo Endereço"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        gradeEnderecosjTable.setName("gradeEnderecosjTable"); // NOI18N
        gradeEnderecosjTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane3.setViewportView(gradeEnderecosjTable);
        gradeEnderecosjTable.getColumnModel().getColumn(0).setResizable(false);
        gradeEnderecosjTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        gradeEnderecosjTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("gradeEnderecosjTable.columnModel.title0")); // NOI18N
        gradeEnderecosjTable.getColumnModel().getColumn(1).setResizable(false);
        gradeEnderecosjTable.getColumnModel().getColumn(1).setPreferredWidth(480);
        gradeEnderecosjTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("gradeEnderecosjTable.columnModel.title1")); // NOI18N
        gradeEnderecosjTable.getColumnModel().getColumn(2).setResizable(false);
        gradeEnderecosjTable.getColumnModel().getColumn(2).setPreferredWidth(60);
        gradeEnderecosjTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("gradeEnderecosjTable.columnModel.title2")); // NOI18N

        enderecosjButton.setIcon(resourceMap.getIcon("enderecosjButton.icon")); // NOI18N
        enderecosjButton.setText(resourceMap.getString("enderecosjButton.text")); // NOI18N
        enderecosjButton.setContentAreaFilled(false);
        enderecosjButton.setName("enderecosjButton"); // NOI18N
        enderecosjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                enderecosjButtonActionPerformed(evt);
            }
        });

        jButton5.setIcon(resourceMap.getIcon("jButton5.icon")); // NOI18N
        jButton5.setText(resourceMap.getString("jButton5.text")); // NOI18N
        jButton5.setContentAreaFilled(false);
        jButton5.setName("jButton5"); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton5, 0, 0, Short.MAX_VALUE)
                    .addComponent(enderecosjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(enderecosjButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel9.setName("jPanel9"); // NOI18N

        jPanel10.setBackground(resourceMap.getColor("jPanel10.background")); // NOI18N
        jPanel10.setName("jPanel10"); // NOI18N

        jPanel11.setName("jPanel11"); // NOI18N

        atualizagradeTelefonejButton.setIcon(resourceMap.getIcon("atualizagradeTelefonejButton.icon")); // NOI18N
        atualizagradeTelefonejButton.setText(resourceMap.getString("atualizagradeTelefonejButton.text")); // NOI18N
        atualizagradeTelefonejButton.setContentAreaFilled(false);
        atualizagradeTelefonejButton.setName("atualizagradeTelefonejButton"); // NOI18N
        atualizagradeTelefonejButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizagradeTelefonejButtonActionPerformed(evt);
            }
        });

        telefonejButton.setIcon(resourceMap.getIcon("telefonejButton.icon")); // NOI18N
        telefonejButton.setText(resourceMap.getString("telefonejButton.text")); // NOI18N
        telefonejButton.setContentAreaFilled(false);
        telefonejButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        telefonejButton.setName("telefonejButton"); // NOI18N
        telefonejButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                telefonejButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(telefonejButton, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(atualizagradeTelefonejButton, javax.swing.GroupLayout.Alignment.TRAILING, 0, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(telefonejButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(atualizagradeTelefonejButton)
                .addContainerGap(33, Short.MAX_VALUE))
        );

        jPanel12.setName("jPanel12"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        identificadorjSpinner.setName("identificadorjSpinner"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setForeground(resourceMap.getColor("jLabel2.foreground")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        pessoajTextField.setText(resourceMap.getString("pessoajTextField.text")); // NOI18N
        pessoajTextField.setName("pessoajTextField"); // NOI18N
        pessoajTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                pessoajTextFieldKeyReleased(evt);
            }
        });

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setForeground(resourceMap.getColor("jLabel3.foreground")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        dataNascimentojFormattedTextField.setFormatterFactory(Funcoes.setFormatoData());
        dataNascimentojFormattedTextField.setText(resourceMap.getString("dataNascimentojFormattedTextField.text")); // NOI18N
        dataNascimentojFormattedTextField.setName("dataNascimentojFormattedTextField"); // NOI18N

        dataFalecimentojFormattedTextField.setFormatterFactory(Funcoes.setFormatoData());
        dataFalecimentojFormattedTextField.setText(resourceMap.getString("dataFalecimentojFormattedTextField.text")); // NOI18N
        dataFalecimentojFormattedTextField.setName("dataFalecimentojFormattedTextField"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setFont(resourceMap.getFont("jLabel5.font")); // NOI18N
        jLabel5.setForeground(resourceMap.getColor("jLabel5.foreground")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        dataCadastrojFormattedTextField.setEditable(false);
        dataCadastrojFormattedTextField.setFormatterFactory(Funcoes.setFormatoData());
        dataCadastrojFormattedTextField.setText(resourceMap.getString("dataCadastrojFormattedTextField.text")); // NOI18N
        dataCadastrojFormattedTextField.setName("dataCadastrojFormattedTextField"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        filiaisjComboBox.setName("filiaisjComboBox"); // NOI18N

        cadastrarFiliaisjButton.setIcon(resourceMap.getIcon("cadastrarFiliaisjButton.icon")); // NOI18N
        cadastrarFiliaisjButton.setText(resourceMap.getString("cadastrarFiliaisjButton.text")); // NOI18N
        cadastrarFiliaisjButton.setToolTipText(resourceMap.getString("cadastrarFiliaisjButton.toolTipText")); // NOI18N
        cadastrarFiliaisjButton.setContentAreaFilled(false);
        cadastrarFiliaisjButton.setName("cadastrarFiliaisjButton"); // NOI18N
        cadastrarFiliaisjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cadastrarFiliaisjButtonActionPerformed(evt);
            }
        });

        atualizaFiliaisjButton.setIcon(resourceMap.getIcon("atualizaFiliaisjButton.icon")); // NOI18N
        atualizaFiliaisjButton.setText(resourceMap.getString("atualizaFiliaisjButton.text")); // NOI18N
        atualizaFiliaisjButton.setContentAreaFilled(false);
        atualizaFiliaisjButton.setName("atualizaFiliaisjButton"); // NOI18N
        atualizaFiliaisjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                atualizaFiliaisjButtonActionPerformed(evt);
            }
        });

        jPanel13.setName("jPanel13"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        gradeTelefonejTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Número", "Operadora", "Tipo Telefone", "Ramal"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        gradeTelefonejTable.setName("gradeTelefonejTable"); // NOI18N
        jScrollPane2.setViewportView(gradeTelefonejTable);
        gradeTelefonejTable.getColumnModel().getColumn(0).setResizable(false);
        gradeTelefonejTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("gradeTelefonejTable.columnModel.title0")); // NOI18N
        gradeTelefonejTable.getColumnModel().getColumn(1).setResizable(false);
        gradeTelefonejTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("gradeTelefonejTable.columnModel.title1")); // NOI18N
        gradeTelefonejTable.getColumnModel().getColumn(2).setResizable(false);
        gradeTelefonejTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("gradeTelefonejTable.columnModel.title2")); // NOI18N
        gradeTelefonejTable.getColumnModel().getColumn(3).setResizable(false);
        gradeTelefonejTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("gradeTelefonejTable.columnModel.title3")); // NOI18N

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 579, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(filiaisjComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, 281, Short.MAX_VALUE)
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(identificadorjSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(pessoajTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(dataNascimentojFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(dataFalecimentojFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4))
                                .addGap(6, 6, 6)
                                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(dataCadastrojFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel12Layout.createSequentialGroup()
                                .addComponent(cadastrarFiliaisjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(atualizaFiliaisjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap())
            .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pessoajTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dataNascimentojFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dataFalecimentojFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dataCadastrojFormattedTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(identificadorjSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(filiaisjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(cadastrarFiliaisjButton))
                    .addComponent(atualizaFiliaisjButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel12, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jPanel14.setName("jPanel14"); // NOI18N

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel6.border.title"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jPanel6.border.titleFont"), resourceMap.getColor("jPanel6.border.titleColor"))); // NOI18N
        jPanel6.setName("jPanel6"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel4.TabConstraints.tabTitle"), jPanel4); // NOI18N

        jPanel8.setBackground(resourceMap.getColor("jPanel8.background")); // NOI18N
        jPanel8.setName("jPanel8"); // NOI18N

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        observacaojTextArea.setColumns(20);
        observacaojTextArea.setRows(5);
        observacaojTextArea.setName("observacaojTextArea"); // NOI18N
        observacaojTextArea.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                observacaojTextAreaKeyTyped(evt);
            }
        });
        jScrollPane4.setViewportView(observacaojTextArea);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 828, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel8.TabConstraints.tabTitle"), jPanel8); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 853, Short.MAX_VALUE)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 853, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 569, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public ClassConecta conexao = new ClassConecta();

    public int id;

    public int codPessoa;

    public int codigo_pessoa;

    ComboItem comboFilial;



//************************************************************************************************************************

       public void getGradePessoa() throws ParseException{
       //Consultar pedidos
        Pessoas oPessoa = new Pessoas();

        if ( pessoajTextField.getText().length() > 0 ){
            oPessoa.setPessoa(pessoajTextField.getText()+"%");
        }

        ResultSet resultSet = null;

        String[] colunasTabela = new String[]{"Código", "Pessoa", "Data Cadastro", "Data Nascimento"};
        DefaultTableModel modeloTabela = new DefaultTableModel(null, colunasTabela) {

            @Override
            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        gradePessoasjTable.setModel(modeloTabela);
        gradePessoasjTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        gradePessoasjTable.getColumnModel().getColumn(1).setPreferredWidth(300);
        gradePessoasjTable.getColumnModel().getColumn(2).setPreferredWidth(80);
        gradePessoasjTable.getColumnModel().getColumn(3).setPreferredWidth(80);

        gradePessoasjTable.setDefaultRenderer(Object.class, new ColorRenderer()); // DEIXA A GRADE ZEBRADA

try {
            resultSet = oPessoa.getConsultar();
            if (resultSet.getRow() == 1){
             resultSet.first();
            }


        } catch (SQLException ex) {
            Logger.getLogger(Pessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {

            while (resultSet.next()) {

                //Formatar data
                Date cadastro = resultSet.getDate("DAT_CADASTRO");

                String dataCadastro = null;
                if (cadastro != null){
                SimpleDateFormat formatoDataLanc = new SimpleDateFormat("dd/MM/yyyy");
                dataCadastro = formatoDataLanc.format(cadastro);
                }else{
                dataCadastro = "";
                }
                //Fim formatação

                //Formatar data
                Date nascimento = resultSet.getDate("DAT_NASC");

                String dataNasc = null;
                if (nascimento != null){
                SimpleDateFormat formatoDataLanc = new SimpleDateFormat("dd/MM/yyyy");
                dataNasc = formatoDataLanc.format(nascimento);
                }else{
                dataNasc = "";
                }
                //Fim formatação

                modeloTabela.addRow(new String[]{
                    Funcoes.getCodigoFormat(resultSet.getInt("cod_pessoa")),
                    resultSet.getString("pessoa"),
                    dataCadastro,
                    dataNasc
                });

            }

        } catch (SQLException ex) {
            Logger.getLogger(Pessoas.class.getName()).log(Level.SEVERE, null, ex);
        }

           }

      public void getFieldPessoas(int codPessoa) throws ParseException{

        Pessoas oPessoa = new Pessoas();
        ResultSet rs = null;
        oPessoa.setCod_pessoa(codPessoa);

        try {
            rs = oPessoa.getConsultar();
            rs.next();

            ComboItem oItem = new ComboItem(rs.getInt("COD_PESSOA"), rs.getString("PESSOA"));
            filiaisjComboBox.setSelectedItem(oItem);

            //Pegar campos
            identificadorjSpinner.setValue(rs.getInt("IDENTIFICADOR"));
            pessoajTextField.setText(rs.getString("PESSOA"));
//            if (dataNascimentojFormattedTextField.getText().equals("  /  /    ")){
//                dataNascimentojFormattedTextField.setText("");
//            }else{
            dataNascimentojFormattedTextField.setValue(Funcoes.getDataFormat(rs.getDate("DAT_NASC")));
//            }
            if (dataFalecimentojFormattedTextField.getText().equals("  /  /    ")){
                dataFalecimentojFormattedTextField.setText("");
            }else{
            dataFalecimentojFormattedTextField.setValue(Funcoes.getDataFormat(rs.getDate("DAT_FALECIMENTO")));
            }

            dataCadastrojFormattedTextField.setValue(Funcoes.getDataFormat(rs.getDate("DAT_CADASTRO")));
            observacaojTextArea.setText(rs.getString("OBS"));
            filiaisjComboBox.setSelectedItem(rs.getString("PESSOA"));

        } catch (SQLException ex) {
            Logger.getLogger(Pessoas.class.getName()).log(Level.SEVERE, null, ex);
        }



    }
//************************************************************************************************************************

      public void getGrandeTelefone() throws ParseException{
       //Consultar pedidos
        Telefones oTelefone = new Telefones();

        ResultSet resultSet = null;

        String[] colunasTabela = new String[]{"Número", "Operadora", "Tipo Telefone", "Ramal"};
        DefaultTableModel modeloTabela = new DefaultTableModel(null, colunasTabela) {

            @Override
            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        gradeTelefonejTable.setModel(modeloTabela);
        gradeTelefonejTable.getColumnModel().getColumn(0).setPreferredWidth(100);
        gradeTelefonejTable.getColumnModel().getColumn(1).setPreferredWidth(100);
        gradeTelefonejTable.getColumnModel().getColumn(2).setPreferredWidth(100);
        gradeTelefonejTable.getColumnModel().getColumn(3).setPreferredWidth(50);

        gradeTelefonejTable.setDefaultRenderer(Object.class, new ColorRenderer());



try {
            oTelefone.setCod_pessoa(codPessoa);

            resultSet = oTelefone.getConsultar();

            if (resultSet.getRow() == 1){
             resultSet.first();
            }


        } catch (SQLException ex) {
            Logger.getLogger(Telefones.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {

            while (resultSet.next()) {

                modeloTabela.addRow(new String[]{
//                    Funcoes.getCodigoFormat(resultSet.getInt("COD_TELEFONE")),
                    resultSet.getString("NUMERO"),
                    resultSet.getString("OPERADORA") ,
                    resultSet.getString("TIPO_TELEFONE"),
                    resultSet.getString("RAMAL"),
                });

            }

        } catch (SQLException ex) {
            Logger.getLogger(Telefones.class.getName()).log(Level.SEVERE, null, ex);
        }

           }

//******************************************************************************************************
    public void getGradeEnderecos() throws ParseException{
       //Consultar Endereços
        PessoasEnderecos oPessoaEndereco= new PessoasEnderecos();


//        if ( logradourojTextField.getText().length() > 0 ){
//            oLogradouro.setLogradouro(logradourojTextField.getText()+"%");
//        }

        ResultSet resultSet = null;

        String[] colunasTabela = new String[]{"#Id", "Endereço", "Tipo Endereço"};
        DefaultTableModel modeloTabela = new DefaultTableModel(null, colunasTabela) {

            @Override
            public boolean isCellEditable(int row, int col) {
                return false;
            }
        };
        gradeEnderecosjTable.setModel(modeloTabela);
        gradeEnderecosjTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        gradeEnderecosjTable.getColumnModel().getColumn(1).setPreferredWidth(480);
        gradeEnderecosjTable.getColumnModel().getColumn(2).setPreferredWidth(60);

        gradeEnderecosjTable.setDefaultRenderer(Object.class, new ColorRenderer());
        
try {


    oPessoaEndereco.setCod_pessoa(codPessoa);
            resultSet = oPessoaEndereco.getConsultar();

            if (resultSet.getRow() == 1){
             resultSet.first();
            }


        } catch (SQLException ex) {
            Logger.getLogger(Logradouros.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {

            while (resultSet.next()) {

                modeloTabela.addRow(new String[]{
                    Funcoes.getCodigoFormat(resultSet.getInt("COD_PESSOA")),
                    resultSet.getString("TIPO")+ " " +resultSet.getString("LOGRADOURO")+ ", " + resultSet.getString("NUMERO")+ ", " 
                            + resultSet.getString("COMPLEMENTO")+ ", " +resultSet.getString("BAIRRO")
                            + ", " + resultSet.getString("CIDADE")+ ", "+ resultSet.getString("ESTADO")+ " - " + resultSet.getString("SIGLA")
                            + " - " + resultSet.getString("PAIS"),
                    resultSet.getString("TIPO_ENDERECO"),
                });

            }

        } catch (SQLException ex) {
            Logger.getLogger(Logradouros.class.getName()).log(Level.SEVERE, null, ex);
        }

           }

    private void sairjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sairjButtonActionPerformed
            // TODO add your handling code here:
            if (!novojButton.isEnabled()){
            try {
                Object[] options = {"Sim", "Não"};
                int sd = JOptionPane.showOptionDialog(null, "Deseja realmente SAIR?", "Confirmação do Sistema!", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
                if (sd != 0) {
                    return;
                }
                
                this.dispose();
                ClassConecta.con.close();

            } catch (SQLException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            }
            }else{
            try {

                this.dispose();
                ClassConecta.con.close();

            } catch (SQLException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            }
            }


    }//GEN-LAST:event_sairjButtonActionPerformed

    private void novojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_novojButtonActionPerformed
        // TODO add your handling code here:
        novojButton.setEnabled(false);
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(false);
        excluirjButton.setEnabled(false);
        buscarjButton.setEnabled(true);
        salvarjButton.setEnabled(true);
        salvarMaisjButton.setEnabled(true);
        cadastrarFiliaisjButton.setEnabled(true);
        pessoajTextField.grabFocus();

        pessoajTextField.setText("");
        dataNascimentojFormattedTextField.setText("");
        dataFalecimentojFormattedTextField.setText("");
        identificadorjSpinner.setValue(0);
    }//GEN-LAST:event_novojButtonActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened

        ClassConecta.conecta();

        atualizaFiliaisjButtonActionPerformed(null);
        try {
            getGradePessoa();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }

        try {
            // TODO add your handling code here:
            dataCadastrojFormattedTextField.setText(Funcoes.getNowBR());
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        } 

    }//GEN-LAST:event_formWindowOpened

    private void salvarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarjButtonActionPerformed

            salvarjButton.setEnabled(false);
            salvarMaisjButton.setEnabled(false);
            alterarjButton.setEnabled(false);
            excluirjButton.setEnabled(false);
            novojButton.setEnabled(true);
            editarjButton.setEnabled(true);
             Pessoas oPessoa = new Pessoas();

             comboFilial = (ComboItem) filiaisjComboBox.getSelectedItem();

            Integer retorno;
                //se tiverem digitado um identificador
            if (!identificadorjSpinner.getValue().equals(0)){
            try {
                //então, verifica se o identificador que a pessoa digitou já existe, e armazena o retorno na variável RETORNO.
                retorno = oPessoa.verificaIdentificador(Integer.parseInt(identificadorjSpinner.getValue().toString()));

                //se retornar algo, quer dizer que o identificador já existe
                if (retorno > 0){
                    //então mande uma mensagem dizendo que o identificador já existe
                    JOptionPane.showMessageDialog(null, "O identificador " + " " + retorno+ " " + "já existe");
                }else{
                    //se não, salve normalmente

                    id = Integer.parseInt(identificadorjSpinner.getValue().toString());

                    identificadorjSpinner.setValue(id);
            oPessoa.setIdentificador(id);
            oPessoa.setPessoa(pessoajTextField.getText().trim().toUpperCase());
            oPessoa.setData_nasc(Funcoes.getDataFormatBR(dataNascimentojFormattedTextField.getText()));

            if (dataFalecimentojFormattedTextField.getText().equals("  /  /    ")){
                dataFalecimentojFormattedTextField.setText("");
            }else{
                oPessoa.setData_falecimento(Funcoes.getDataFormatBR(dataFalecimentojFormattedTextField.getText()));
            }

            oPessoa.setData_cadastro(Funcoes.getDataFormatBR(dataCadastrojFormattedTextField.getText()));
            oPessoa.setCod_filial(comboFilial.getId());
            oPessoa.setCadastrar();

                ClassConecta.con.commit();
                ClassConecta.con.setAutoCommit(true);
                }
            } catch (SQLException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ParseException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            }
            // SE O CAMPO IDENTIFICADOR FOR IGUAL A ( ZERO ) (O ISUARIO NÃO DIGITOU UM NUMERO PARA O IDENTIFICADOR)

            }else{
            try {
                id = oPessoa.getId();
                retorno = oPessoa.verificaIdentificador((id));
                if (retorno == id){
                    JOptionPane.showMessageDialog(null, "numero igual acrescentar mais um");
                }
                id++;
                identificadorjSpinner.setValue(id);
                oPessoa.setIdentificador(id);
                oPessoa.setPessoa(pessoajTextField.getText().trim().toUpperCase());
                oPessoa.setData_nasc(Funcoes.getDataFormatBR(dataNascimentojFormattedTextField.getText()));
                if (dataFalecimentojFormattedTextField.getText().equals("  /  /    ")) {
                    dataFalecimentojFormattedTextField.setText("");
                } else {
                    oPessoa.setData_falecimento(Funcoes.getDataFormatBR(dataFalecimentojFormattedTextField.getText()));
                }
                oPessoa.setData_cadastro(Funcoes.getDataFormatBR(dataCadastrojFormattedTextField.getText()));
                oPessoa.setCod_filial(comboFilial.getId());
                oPessoa.setCadastrar();

                ClassConecta.con.commit();
                ClassConecta.con.setAutoCommit(true);
                getGradePessoa();

            } catch (ParseException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            }
            }
    }//GEN-LAST:event_salvarjButtonActionPerformed

    private void pessoaFisicajButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pessoaFisicajButtonActionPerformed
        // TODO add your handling code here:
            jFPessoaFisica oPessoaFisica = new jFPessoaFisica();
            oPessoaFisica.conexao = conexao;
            oPessoaFisica.cod_pessoa_pessoaFisica = codPessoa;
            oPessoaFisica.setTitle("Cadastro Pessoa Física");
            oPessoaFisica.pack();
            oPessoaFisica.setLocationRelativeTo(null);
            oPessoaFisica.setModal(true);
            oPessoaFisica.setVisible(true);


    }//GEN-LAST:event_pessoaFisicajButtonActionPerformed

    private void salvarMaisjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarMaisjButtonActionPerformed
        // TODO add your handling code here:
         salvarjButtonActionPerformed(null);
         novojButtonActionPerformed(null);
    }//GEN-LAST:event_salvarMaisjButtonActionPerformed

    private void buscarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarjButtonActionPerformed
        try {
            // TODO add your handling code here:
            getGradePessoa();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_buscarjButtonActionPerformed

    private void gradePessoasjTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gradePessoasjTableMouseClicked
        try {
            Pessoas oPessoa = new Pessoas();
            // TODO add your handling code here:
            editarjButton.setEnabled(true);
            codPessoa = Integer.parseInt(gradePessoasjTable.getValueAt(gradePessoasjTable.getSelectedRow(), 0).toString());

            getGrandeTelefone();
            getGradeEnderecos();

            if (codPessoa == 0) {


                if (dataFalecimentojFormattedTextField.getText().equals("  /  /    ")){
                dataFalecimentojFormattedTextField.setText("");
            }else{
                oPessoa.setData_falecimento(Funcoes.getDataFormatBR(dataFalecimentojFormattedTextField.getText()));
            }
                return;
            }
            if (dataFalecimentojFormattedTextField.getText().equals("  /  /    ")){
                dataFalecimentojFormattedTextField.setText("");
            }else{
                oPessoa.setData_falecimento(Funcoes.getDataFormatBR(dataFalecimentojFormattedTextField.getText()));
            }
            getFieldPessoas(codPessoa);
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
        telefonejButton.setEnabled(true);
        enderecosjButton.setEnabled(true);
        pessoaFisicajButton.setEnabled(true);
        pessoaJuridicajButton.setEnabled(true);
        filiaisjButton.setEnabled(true);
        fornecedoresjButton.setEnabled(true);
        cadastrarFiliaisjButton.setEnabled(true);
    }//GEN-LAST:event_gradePessoasjTableMouseClicked

    private void pessoajTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_pessoajTextFieldKeyReleased
        // TODO add your handling code here:
        if (!alterarjButton.isEnabled()){
            try {
                Pessoas oPessoa = new Pessoas();
                oPessoa.setPessoa(pessoajTextField.getText());
                ResultSet rs = null;
                rs = oPessoa.getConsultar();
                getGradePessoa();
            } catch (ParseException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
                    }
    }
                if(pessoajTextField.getText().equals("")){
            identificadorjSpinner.setValue(0);
            pessoajTextField.setText("");
            dataNascimentojFormattedTextField.setText("");
            dataFalecimentojFormattedTextField.setText("");
            dataCadastrojFormattedTextField.setText("");
            observacaojTextArea.setText("");
            try {
                dataCadastrojFormattedTextField.setText(Funcoes.getNowBR());
            } catch (ParseException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            }
                }
        if(pessoajTextField.getText().equals("")){
            editarjButton.setEnabled(false);
        }
    }//GEN-LAST:event_pessoajTextFieldKeyReleased

    private void editarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editarjButtonActionPerformed
        // TODO add your handling code here:
            novojButton.setEnabled(false);
            salvarjButton.setEnabled(false);
            salvarMaisjButton.setEnabled(false);
            editarjButton.setEnabled(false);
            alterarjButton.setEnabled(true);
            excluirjButton.setEnabled(true);
        try {
            ClassConecta.con.setAutoCommit(false);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_editarjButtonActionPerformed

    private void alterarjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alterarjButtonActionPerformed
        // TODO add your handling code here:
            alterarjButton.setEnabled(false);
            editarjButton.setEnabled(true);
            excluirjButton.setEnabled(false);
            novojButton.setEnabled(true);

            Pessoas oPessoa = new Pessoas();
            oPessoa.setCod_pessoa(codPessoa);

            id = Integer.parseInt(identificadorjSpinner.getValue().toString());
            comboFilial = (ComboItem) filiaisjComboBox.getSelectedItem();

            
        try {
            oPessoa.setIdentificador(id);
            oPessoa.setPessoa(pessoajTextField.getText().trim().toUpperCase());
            oPessoa.setData_cadastro(Funcoes.getDataFormatBR(dataCadastrojFormattedTextField.getText()));
            if (dataNascimentojFormattedTextField.getText().equals("  /  /    ")){
                dataNascimentojFormattedTextField.setText("");
            }else{
                oPessoa.setData_nasc(Funcoes.getDataFormatBR(dataNascimentojFormattedTextField.getText()));
            }
            if (dataFalecimentojFormattedTextField.getText().equals("  /  /    ")){
                dataFalecimentojFormattedTextField.setText("");
            }else{
                oPessoa.setData_falecimento(Funcoes.getDataFormatBR(dataFalecimentojFormattedTextField.getText()));
            }
            oPessoa.setObservacao(observacaojTextArea.getText());
            oPessoa.setCod_filial(comboFilial.getId());
            oPessoa.setAlterar(conexao);
            try {
                ClassConecta.con.commit();
                ClassConecta.con.setAutoCommit(true);
            } catch (SQLException ex) {
                Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
            }


            getGradePessoa();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_alterarjButtonActionPerformed

    private void excluirjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excluirjButtonActionPerformed
        // TODO add your handling code here:
        Object[] options = {"Sim", "Não"};
        int sd =
                JOptionPane.showOptionDialog(null, "Deseja realmente EXCLUIR esse registro?", "Confirmação!", JOptionPane.DEFAULT_OPTION,
                JOptionPane.WARNING_MESSAGE, null, options, options[0]);

        if (sd != 0) {
            return;
        }
        alterarjButton.setEnabled(false);
        editarjButton.setEnabled(true);
        excluirjButton.setEnabled(false);
        novojButton.setEnabled(true);

        int codPessoaDelete = 0;
        codPessoaDelete = Integer.parseInt(gradePessoasjTable.getValueAt(gradePessoasjTable.getSelectedRow(), 0).toString());

        Pessoas oPessoa = new Pessoas();
        oPessoa.setCod_pessoa(codPessoaDelete);
        oPessoa.setExcluir(conexao);
        try {
            ClassConecta.con.commit();
            ClassConecta.con.setAutoCommit(true);
        } catch (SQLException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
        identificadorjSpinner.setValue(0);
        pessoajTextField.setText("");
        dataNascimentojFormattedTextField.setText("");
        dataFalecimentojFormattedTextField.setText("");
        try {
            dataCadastrojFormattedTextField.setText(Funcoes.getNowBR());
            getGradePessoa();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_excluirjButtonActionPerformed

    private void telefonejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_telefonejButtonActionPerformed
        try {
            // TODO add your handling code here:
            jFTelefones oFormTelefone = new jFTelefones();
            oFormTelefone.conexao = conexao;
            System.out.println(codPessoa);
            oFormTelefone.codPessoaTelefone = codPessoa;
            oFormTelefone.setTitle("Cadastro Telefones");
            oFormTelefone.pack();
            oFormTelefone.setLocationRelativeTo(null);
            oFormTelefone.setModal(true);
            oFormTelefone.setVisible(true);
            getGrandeTelefone();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_telefonejButtonActionPerformed

    private void atualizagradeTelefonejButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizagradeTelefonejButtonActionPerformed
        try {
            // Atualiza a grade de telefones
            getGrandeTelefone();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizagradeTelefonejButtonActionPerformed

    private void enderecosjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enderecosjButtonActionPerformed
        // TODO add your handling code here:
        jFPessoasEnderecos oFormPessoasEnderecos = new jFPessoasEnderecos();

        oFormPessoasEnderecos.setDefaultCloseOperation(jFPessoasEnderecos.DO_NOTHING_ON_CLOSE);
        oFormPessoasEnderecos.cod_pessoa = codPessoa;
        oFormPessoasEnderecos.pack();
        oFormPessoasEnderecos.setLocationRelativeTo(null);
        oFormPessoasEnderecos.setModal(true);
        oFormPessoasEnderecos.setVisible(true);
        try {
            getGradeEnderecos();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_enderecosjButtonActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        try {
            // TODO add your handling code here:
            getGradeEnderecos();
        } catch (ParseException ex) {
            Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void pessoaJuridicajButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pessoaJuridicajButtonActionPerformed
        // TODO add your handling code here:
            jFPessoaJuridica oPessoaJuridica = new jFPessoaJuridica();
            oPessoaJuridica.conexao = conexao;
            oPessoaJuridica.cod_pessoa_juridica = codPessoa;
            oPessoaJuridica.setTitle("Cadastro Pessoa Jurídica");
            oPessoaJuridica.pack();
            oPessoaJuridica.setLocationRelativeTo(null);
            oPessoaJuridica.setModal(true);
            oPessoaJuridica.setVisible(true);
    }//GEN-LAST:event_pessoaJuridicajButtonActionPerformed

    private void filiaisjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filiaisjButtonActionPerformed
        // TODO add your handling code here:
            jFFiliais oFormFiliais = new jFFiliais();

            oFormFiliais.conexao = conexao;
            oFormFiliais.cod_filiais = codPessoa;
            oFormFiliais.setTitle("Cadastro de Filiais");
            oFormFiliais.pack();
            oFormFiliais.setLocationRelativeTo(null);
            oFormFiliais.setModal(true);
            oFormFiliais.setVisible(true);
    }//GEN-LAST:event_filiaisjButtonActionPerformed

    private void fornecedoresjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fornecedoresjButtonActionPerformed
        // TODO add your handling code here:
            jFFornecedores oFormFornecedor = new jFFornecedores();

            oFormFornecedor.conexao = conexao;
            oFormFornecedor.cod_pessoas_fornecedores = codPessoa;
            oFormFornecedor.setTitle("Cadastro de Fornecedores");
            oFormFornecedor.pack();
            oFormFornecedor.setLocationRelativeTo(null);
            oFormFornecedor.setModal(true);
            oFormFornecedor.setVisible(true);
    }//GEN-LAST:event_fornecedoresjButtonActionPerformed

    private void observacaojTextAreaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_observacaojTextAreaKeyTyped
        // TODO add your handling code here:
        observacaojTextArea.setLineWrap(true);
        observacaojTextArea.setWrapStyleWord(true);
    }//GEN-LAST:event_observacaojTextAreaKeyTyped

    private void cadastrarFiliaisjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastrarFiliaisjButtonActionPerformed
        // TODO add your handling code here:
        jFFiliais oFormFiliais = new jFFiliais();

            oFormFiliais.conexao = conexao;
            oFormFiliais.cod_filiais = codPessoa;
            oFormFiliais.setTitle("Cadastro de Filiais");
            oFormFiliais.pack();
            oFormFiliais.setLocationRelativeTo(null);
            oFormFiliais.setModal(true);
            oFormFiliais.setVisible(true);
    }//GEN-LAST:event_cadastrarFiliaisjButtonActionPerformed

    private void atualizaFiliaisjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_atualizaFiliaisjButtonActionPerformed
        // TODO add your handling code here:
        try {
            Filiais oFilial = new Filiais();
            ResultSet rs = null;

            rs = oFilial.getConsultar();
            filiaisjComboBox.removeAllItems();
            filiaisjComboBox.addItem("");
            while (rs.next()) {
                filiaisjComboBox.addItem(new ComboItem(rs.getInt("COD_PESSOA"), rs.getString("PESSOA")));
            }
            filiaisjComboBox.updateUI();
        } catch (SQLException ex) {
            Logger.getLogger(Filiais.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_atualizaFiliaisjButtonActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new jFPessoas().setVisible(true);
                } catch (ParseException ex) {
                    Logger.getLogger(jFPessoas.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton alterarjButton;
    private javax.swing.JButton atualizaFiliaisjButton;
    private javax.swing.JButton atualizagradeTelefonejButton;
    private javax.swing.JButton buscarjButton;
    private javax.swing.JButton cadastrarFiliaisjButton;
    private javax.swing.JFormattedTextField dataCadastrojFormattedTextField;
    private javax.swing.JFormattedTextField dataFalecimentojFormattedTextField;
    private javax.swing.JFormattedTextField dataNascimentojFormattedTextField;
    private javax.swing.JButton editarjButton;
    private javax.swing.JButton enderecosjButton;
    private javax.swing.JButton excluirjButton;
    private javax.swing.JButton filiaisjButton;
    private javax.swing.JComboBox filiaisjComboBox;
    private javax.swing.JButton fornecedoresjButton;
    private javax.swing.JTable gradeEnderecosjTable;
    private javax.swing.JTable gradePessoasjTable;
    private javax.swing.JTable gradeTelefonejTable;
    private javax.swing.JSpinner identificadorjSpinner;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton novojButton;
    private javax.swing.JTextArea observacaojTextArea;
    private javax.swing.JButton pessoaFisicajButton;
    private javax.swing.JButton pessoaJuridicajButton;
    private javax.swing.JTextField pessoajTextField;
    private javax.swing.JButton sairjButton;
    private javax.swing.JButton salvarMaisjButton;
    private javax.swing.JButton salvarjButton;
    private javax.swing.JButton telefonejButton;
    // End of variables declaration//GEN-END:variables

}
